﻿Imports System.Data
Imports System.Data.SqlClient

Public Class Autent2

    Dim password1 As String
    Dim numero As String


    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

        Try
            Dim strCon As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
            Dim sql As String = "select pass,numeroserie from trabajador where rut_trabajador='" & textBox1.Text & "';"
            Dim tabla As New DataTable
            Dim adaptador As New SqlDataAdapter(sql, strCon)
            adaptador.Fill(tabla)

            password1 = tabla.Rows(0)("pass")
            numero = tabla.Rows(0)("numeroserie")

        Catch ex As Exception
            MsgBox("Usuario no registrado", MsgBoxStyle.Critical, "Error")
            GoTo salto
        End Try

        If textBox2.Text = numero Then
            Label4.Text = password1
        Else
            MsgBox("Numero de serie incorrecto", MsgBoxStyle.Information, "Error")
        End If

salto:
    End Sub



    Private Sub textBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox2.KeyPress
        If e.KeyChar = Convert.ToChar(Keys.Return) Then
            Me.button1.PerformClick()
            e.Handled = True
        End If
    End Sub




End Class